# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass=print-machine-cycles -o - %s 2>&1 | FileCheck %s

...
---
# CHECK-LABEL: MachineCycleInfo for function: empty
name:            empty
alignment:       16
tracksRegLiveness: true
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: simple
# CHECK:           depth=1: entries(bb.1)
name:            simple
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    JMP_1 %bb.1

  bb.1:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.2

  bb.2:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: two_latches
# CHECK:           depth=1: entries(bb.1) bb.2
name:            two_latches
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    JMP_1 %bb.1

  bb.1:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.2

  bb.2:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.3, 5, implicit $eflags
    JMP_1 %bb.1

  bb.3:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: nested_simple
# CHECK:           depth=1: entries(bb.1) bb.3 bb.2
# CHECK:               depth=2: entries(bb.2)
name:            nested_simple
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    JMP_1 %bb.1

  bb.1:
    JMP_1 %bb.2

  bb.2:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.3

  bb.3:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.4

  bb.4:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: nested_outer_latch_in_inner_loop
# CHECK:           depth=1: entries(bb.1) bb.2 bb.3
# CHECK:               depth=2: entries(bb.2) bb.3
name:            nested_outer_latch_in_inner_loop
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    JMP_1 %bb.1

  bb.1:
    JMP_1 %bb.2

  bb.2:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.3, 5, implicit $eflags
    JMP_1 %bb.1

  bb.3:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.4, 5, implicit $eflags
    JMP_1 %bb.2

  bb.4:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: sibling_loops
# CHECK:           depth=1: entries(bb.1)
# CHECK:           depth=1: entries(bb.2)
name:            sibling_loops
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
  - { id: 2, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.2

  bb.1:
    %2:gr8 = IMPLICIT_DEF
    TEST8ri %2, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.3

  bb.2:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.3

  bb.3:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: serial_loops
# CHECK:           depth=1: entries(bb.2)
# CHECK:           depth=1: entries(bb.1)
name:            serial_loops
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    JMP_1 %bb.1

  bb.1:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.2

  bb.2:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.3

  bb.3:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: nested_sibling_loops
# CHECK:           depth=1: entries(bb.1) bb.4 bb.5 bb.3 bb.2
# CHECK:               depth=2: entries(bb.4) bb.5
# CHECK:               depth=2: entries(bb.2)
name:            nested_sibling_loops
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr32 }
  - { id: 2, class: gr8 }
  - { id: 3, class: gr32 }
  - { id: 4, class: gr8 }
  - { id: 5, class: gr32 }
  - { id: 6, class: gr8 }
  - { id: 7, class: gr32 }
  - { id: 8, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    JMP_1 %bb.1

  bb.1:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.3

  bb.2:
    %5:gr32 = MOV32r0 implicit-def dead $eflags
    %6:gr8 = COPY %5.sub_8bit
    TEST8rr %6, %6, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.6

  bb.6:
    %7:gr32 = MOV32r0 implicit-def dead $eflags
    %8:gr8 = COPY %7.sub_8bit
    TEST8rr %8, %8, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.4

  bb.3:
    %1:gr32 = MOV32r0 implicit-def dead $eflags
    %2:gr8 = COPY %1.sub_8bit
    TEST8rr %2, %2, implicit-def $eflags
    JCC_1 %bb.4, 5, implicit $eflags
    JMP_1 %bb.5

  bb.5:
    %3:gr32 = MOV32r0 implicit-def dead $eflags
    %4:gr8 = COPY %3.sub_8bit
    TEST8rr %4, %4, implicit-def $eflags
    JCC_1 %bb.3, 5, implicit $eflags
    JMP_1 %bb.1

  bb.4:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: deeper_nest
# CHECK:           depth=1: entries(bb.1) bb.5 bb.2 bb.3 bb.4
# CHECK:               depth=2: entries(bb.2) bb.3 bb.4
# CHECK:                   depth=3: entries(bb.3) bb.4
name:            deeper_nest
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
  - { id: 2, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    JMP_1 %bb.1

  bb.1:
    JMP_1 %bb.2

  bb.2:
    JMP_1 %bb.3

  bb.3:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.4

  bb.4:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.3, 5, implicit $eflags
    JMP_1 %bb.5

  bb.5:
    %2:gr8 = IMPLICIT_DEF
    TEST8ri %2, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.6

  bb.6:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: irreducible_basic
# CHECK:           depth=1: entries(bb.2 bb.1)
name:            irreducible_basic
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
  - { id: 2, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.2

  bb.1:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.3

  bb.2:
    %2:gr8 = IMPLICIT_DEF
    TEST8ri %2, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.3

  bb.3:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: irreducible_mess
# CHECK:           depth=1: entries(bb.2 bb.1) bb.6 bb.5 bb.3 bb.4
# CHECK:               depth=2: entries(bb.5 bb.3 bb.1) bb.4
# CHECK:                   depth=3: entries(bb.3 bb.1) bb.4
name:            irreducible_mess
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
  - { id: 2, class: gr32 }
  - { id: 3, class: gr8 }
  - { id: 4, class: gr32 }
  - { id: 5, class: gr8 }
  - { id: 6, class: gr32 }
  - { id: 7, class: gr8 }
  - { id: 8, class: gr32 }
  - { id: 9, class: gr8 }
  - { id: 10, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.2

  bb.1:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.3, 5, implicit $eflags
    JMP_1 %bb.4

  bb.2:
    %10:gr8 = IMPLICIT_DEF
    TEST8ri %10, 1, implicit-def $eflags
    JCC_1 %bb.3, 5, implicit $eflags
    JMP_1 %bb.4

  bb.3:
    %2:gr32 = MOV32r0 implicit-def dead $eflags
    %3:gr8 = COPY %2.sub_8bit
    TEST8rr %3, %3, implicit-def $eflags
    JCC_1 %bb.4, 5, implicit $eflags
    JMP_1 %bb.6

  bb.6:
    %4:gr32 = MOV32r0 implicit-def dead $eflags
    %5:gr8 = COPY %4.sub_8bit
    TEST8rr %5, %5, implicit-def $eflags
    JCC_1 %bb.5, 5, implicit $eflags
    JMP_1 %bb.1

  bb.4:
    %6:gr32 = MOV32r0 implicit-def dead $eflags
    %7:gr8 = COPY %6.sub_8bit
    TEST8rr %7, %7, implicit-def $eflags
    JCC_1 %bb.3, 5, implicit $eflags
    JMP_1 %bb.7

  bb.7:
    successors: %bb.5, %bb.2

    %8:gr32 = MOV32r0 implicit-def dead $eflags
    %9:gr8 = COPY %8.sub_8bit
    TEST8rr %9, %9, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.5

  bb.5:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: irreducible_into_simple_cycle
# CHECK:           depth=1: entries(bb.2 bb.7 bb.4) bb.6 bb.5 bb.3
name:            irreducible_into_simple_cycle
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr32 }
  - { id: 1, class: gr8 }
  - { id: 2, class: gr32 }
  - { id: 3, class: gr8 }
  - { id: 4, class: gr8 }
  - { id: 5, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    %0:gr32 = MOV32r0 implicit-def dead $eflags
    %1:gr8 = COPY %0.sub_8bit
    TEST8rr %1, %1, implicit-def $eflags
    JCC_1 %bb.3, 5, implicit $eflags
    JMP_1 %bb.8

  bb.8:
    %2:gr32 = MOV32r0 implicit-def dead $eflags
    %3:gr8 = COPY %2.sub_8bit
    TEST8rr %3, %3, implicit-def $eflags
    JCC_1 %bb.6, 5, implicit $eflags
    JMP_1 %bb.1

  bb.1:
    JMP_1 %bb.2

  bb.2:
    JMP_1 %bb.3

  bb.3:
    JMP_1 %bb.4

  bb.4:
    %4:gr8 = IMPLICIT_DEF
    TEST8ri %4, 1, implicit-def $eflags
    JCC_1 %bb.5, 5, implicit $eflags
    JMP_1 %bb.7

  bb.5:
    JMP_1 %bb.6

  bb.6:
    %5:gr8 = IMPLICIT_DEF
    TEST8ri %5, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.7

  bb.7:
    RET64

...
---
# CHECK-LABEL: MachineCycleInfo for function: irreducible_mountain_bug
# CHECK:           depth=1: entries(bb.6) bb.11 bb.10 bb.8 bb.7 bb.9 bb.12
# CHECK:               depth=2: entries(bb.10 bb.7) bb.8 bb.9
# CHECK:                   depth=3: entries(bb.8 bb.7) bb.9
name:            irreducible_mountain_bug
alignment:       16
tracksRegLiveness: true
registers:
  - { id: 0, class: gr8 }
  - { id: 1, class: gr8 }
  - { id: 2, class: gr8 }
  - { id: 3, class: gr8 }
  - { id: 4, class: gr8 }
  - { id: 5, class: gr8 }
  - { id: 6, class: gr8 }
  - { id: 7, class: gr8 }
  - { id: 8, class: gr8 }
  - { id: 9, class: gr8 }
  - { id: 10, class: gr8 }
  - { id: 11, class: gr8 }
  - { id: 12, class: gr8 }
  - { id: 13, class: gr8 }
frameInfo:
  maxAlignment:    1
machineFunctionInfo: {}
body:             |
  bb.0:
    %0:gr8 = IMPLICIT_DEF
    TEST8ri %0, 1, implicit-def $eflags
    JCC_1 %bb.1, 5, implicit $eflags
    JMP_1 %bb.17

  bb.1:
    %3:gr8 = IMPLICIT_DEF
    TEST8ri %3, 1, implicit-def $eflags
    JCC_1 %bb.2, 5, implicit $eflags
    JMP_1 %bb.3

  bb.2:
    JMP_1 %bb.4

  bb.3:
    JMP_1 %bb.4

  bb.4:
    %4:gr8 = IMPLICIT_DEF
    TEST8ri %4, 1, implicit-def $eflags
    JCC_1 %bb.5, 5, implicit $eflags
    JMP_1 %bb.14

  bb.5:
    JMP_1 %bb.6

  bb.6:
    %7:gr8 = IMPLICIT_DEF
    TEST8ri %7, 1, implicit-def $eflags
    JCC_1 %bb.7, 5, implicit $eflags
    JMP_1 %bb.12

  bb.7:
    %9:gr8 = IMPLICIT_DEF
    TEST8ri %9, 1, implicit-def $eflags
    JCC_1 %bb.11, 5, implicit $eflags
    JMP_1 %bb.8

  bb.8:
    %10:gr8 = IMPLICIT_DEF
    TEST8ri %10, 1, implicit-def $eflags
    JCC_1 %bb.20, 5, implicit $eflags
    JMP_1 %bb.9

  bb.9:
    %11:gr8 = IMPLICIT_DEF
    TEST8ri %11, 1, implicit-def $eflags
    JCC_1 %bb.7, 5, implicit $eflags
    JMP_1 %bb.10

  bb.10:
    %12:gr8 = IMPLICIT_DEF
    TEST8ri %12, 1, implicit-def $eflags
    JCC_1 %bb.8, 5, implicit $eflags
    JMP_1 %bb.6

  bb.11:
    %13:gr8 = IMPLICIT_DEF
    TEST8ri %13, 1, implicit-def $eflags
    JCC_1 %bb.20, 5, implicit $eflags
    JMP_1 %bb.6

  bb.12:
    %8:gr8 = IMPLICIT_DEF
    TEST8ri %8, 1, implicit-def $eflags
    JCC_1 %bb.10, 5, implicit $eflags
    JMP_1 %bb.13

  bb.13:
    JMP_1 %bb.20

  bb.14:
    %5:gr8 = IMPLICIT_DEF
    TEST8ri %5, 1, implicit-def $eflags
    JCC_1 %bb.20, 5, implicit $eflags
    JMP_1 %bb.15

  bb.15:
    %6:gr8 = IMPLICIT_DEF
    TEST8ri %6, 1, implicit-def $eflags
    JCC_1 %bb.20, 5, implicit $eflags
    JMP_1 %bb.16

  bb.16:
    JMP_1 %bb.20

  bb.17:
    %1:gr8 = IMPLICIT_DEF
    TEST8ri %1, 1, implicit-def $eflags
    JCC_1 %bb.20, 5, implicit $eflags
    JMP_1 %bb.18

  bb.18:
    %2:gr8 = IMPLICIT_DEF
    TEST8ri %2, 1, implicit-def $eflags
    JCC_1 %bb.20, 5, implicit $eflags
    JMP_1 %bb.19

  bb.19:
    JMP_1 %bb.20

  bb.20:
    RET64

...
